package com.easemob.helpdesk.utils;

import android.app.Dialog;
import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.housekeeperapp.R;

public class DialogUtils {


	public static Dialog getLoadingDialog(Context context, CharSequence loadingMsg) {
		Dialog mDialog = new Dialog(context, R.style.progress_dialog);
		mDialog.setContentView(R.layout.dialog);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(true);
		mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
		TextView msg = (TextView) mDialog.findViewById(R.id.id_tv_loadingmsg);
		msg.setText(loadingMsg);
		return mDialog;
	}

	public static Dialog getLoadingDialog(Context context, int resid) {
		return getLoadingDialog(context, context.getResources().getText(resid));
	}

	public static Dialog getFailOrderDialog(Context context, CharSequence loadingMsg){
		final Dialog mDialog = new Dialog(context, R.style.MyDialogStyle);
		mDialog.setContentView(R.layout.dialog_fail_order);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(true);

		new CountDownTimer(5000, 1000) {
			@Override
			public void onTick(long millisUntilFinished) {

			}
			@Override
			public void onFinish() {
				try {
					mDialog.dismiss();
				}catch (Exception e){
					System.out.print(e.getMessage().toString());
				}

			}
		}.start();

//		mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
//		TextView msg = (TextView) mDialog.findViewById(R.id.id_tv_loadingmsg);
//		msg.setText(loadingMsg);
		return mDialog;
	}
}
